public class Leet304 {
        static int[][] m = {
                {3, 0, 1, 4, 2},
    {5, 6, 3, 2, 1},
    {1, 2, 0, 1, 5},
    {4, 1, 0, 1, 7},
    {1, 0, 3, 0, 5}};
        public void NumMatrix(int[][] matrix) {
            m = matrix;
        }

        public int sumRegion(int row1, int col1, int row2, int col2) {
            int num = 0;
            for(int i = row1;i<row2+1;i++){
                for(int j = col1;j<col2+1;j++){
                    num+=m[i][j];
                }
            }
            return num;
        }
    public static void main(String[] args) {
            Leet304 l = new Leet304();
        System.out.println(l.sumRegion(2,1,4,3));
    }
}
